package com.sugar.psych.assessment.module.business.controller.app.userpointsrecord.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.List;

import static com.sugar.psych.assessment.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;

@Schema(description = "App - 用户积分记录 Response VO")
@Data
public class AppUserPointsRecordRespVO {

    @Schema(description = "月份日期", requiredMode = Schema.RequiredMode.REQUIRED)
    private String month;

    @Schema(description = "当月积分记录", requiredMode = Schema.RequiredMode.REQUIRED)
    private List<PointRecord> points;


    @Data
    public static class PointRecord {

        @Schema(description = "标题", requiredMode = Schema.RequiredMode.REQUIRED)
        private String title;

        @Schema(description = "月份", requiredMode = Schema.RequiredMode.REQUIRED)
        private String monthItem;

        @Schema(description = "变动类型（0减 1增）", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
        private Boolean type;

        @Schema(description = "积分变动数量", requiredMode = Schema.RequiredMode.REQUIRED)
        private Integer obtainedPoints;

        @Schema(description = "记录时间", requiredMode = Schema.RequiredMode.REQUIRED)
        @JsonSerialize(using = LocalDateTimeSerializer.class) // 序列化（响应）
        @JsonDeserialize(using = LocalDateTimeDeserializer.class) // 反序列化（请求）
        @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
        private LocalDateTime recordTime;
    }
}